var t = require("../../../../@babel/runtime/helpers/defineProperty");

Component({
    properties: {
        levelList: {
            type: [ String, Array, Object ],
            value: []
        },
        groupsList: {
            type: [ String, Array, Object ],
            value: []
        },
        widgetsInfo: {
            type: [ String, Number, Object ],
            value: {}
        }
    },
    data: {
        isShowPopup: !1,
        popTitle: "",
        show_levels_CheckedAll: !1,
        buy_levels_CheckedAll: !1,
        show_groups_CheckedAll: !1,
        buy_groups_CheckedAll: !1,
        show1: !1,
        show2: !1,
        show3: !1,
        show4: !1,
        buy_levels: [],
        show_levels: [],
        show_groups: [],
        buy_groups: [],
        once_buy_limit: "",
        total_buy_limit: "",
        day_buy_limit: "",
        week_buy_limit: "",
        month_buy_limit: "",
        hyll_Model: "",
        hygm_Model: "",
        hyzll_Model: "",
        hyzgm_Model: ""
    },
    lifetimes: {
        attached: function() {
            this.getDataInfo();
        }
    },
    methods: {
        changeType: function(e) {
            var i = e.currentTarget.dataset.name;
            this.setData(t({}, i, e.detail));
        },
        getDataInfo: function() {
            if (this.data.widgetsInfo && this.data.widgetsInfo.privilege) {
                var t = this.data.widgetsInfo.privilege, e = t.show_levels, i = t.show_groups, s = t.buy_levels, o = t.buy_groups, l = t.once_buy_limit, a = t.total_buy_limit, u = t.day_buy_limit, r = t.week_buy_limit, n = t.month_buy_limit, _ = {};
                _.show_levels = e ? e.map(function(t) {
                    return t;
                }) : [], _.show_groups = i ? i.map(function(t) {
                    return t;
                }) : [], _.buy_levels = s ? s.map(function(t) {
                    return t;
                }) : [], _.buy_groups = o ? o.map(function(t) {
                    return t;
                }) : [], _.once_buy_limit = String(l), _.total_buy_limit = String(a), _.day_buy_limit = String(u), 
                _.week_buy_limit = String(r), _.month_buy_limit = String(n), this.setData(_);
            }
        },
        validatorData: function() {
            return {
                show_levels: this.data.show_levels,
                buy_levels: this.data.buy_levels,
                show_groups: this.data.show_groups,
                buy_groups: this.data.buy_groups,
                once_buy_limit: this.data.once_buy_limit,
                total_buy_limit: this.data.total_buy_limit,
                day_buy_limit: this.data.day_buy_limit,
                week_buy_limit: this.data.week_buy_limit,
                month_buy_limit: this.data.month_buy_limit
            };
        },
        setShowPopup: function(t) {
            var e = t.currentTarget.dataset.index;
            switch (this.setData({
                isShowPopup: !0,
                show1: !1,
                show2: !1,
                show3: !1,
                show4: !1
            }), e) {
              case 1:
                this.setData({
                    popTitle: "会员等级浏览权限",
                    show1: !0
                });
                break;

              case 2:
                this.setData({
                    popTitle: "会员等级购买权限",
                    show2: !0
                });
                break;

              case 3:
                this.setData({
                    popTitle: "会员组浏览权限",
                    show3: !0
                });
                break;

              case 4:
                this.setData({
                    popTitle: "会员组购买权限",
                    show4: !0
                });
            }
        },
        cancelShowPop: function() {
            this.setData({
                isShowPopup: !1
            });
        }
    },
    observers: {
        show_levels: function(t) {
            var e = this.properties.levelList.filter(function(e) {
                return -1 != t.indexOf(e.id + "");
            }).map(function(t) {
                return t.level_name;
            });
            this.setData({
                hyll_Model: e.join(",")
            });
        },
        buy_levels: function(t) {
            var e = this.properties.levelList.filter(function(e) {
                return -1 != t.indexOf(e.id + "");
            }).map(function(t) {
                return t.level_name;
            });
            this.setData({
                hygm_Model: e.join(",")
            });
        },
        show_groups: function(t) {
            var e = this.properties.groupsList.filter(function(e) {
                return -1 != t.indexOf(e.id + "");
            }).map(function(t) {
                return t.group_name;
            });
            this.setData({
                hyzll_Model: e.join(",")
            });
        },
        buy_groups: function(t) {
            var e = this.properties.groupsList.filter(function(e) {
                return -1 != t.indexOf(e.id + "");
            }).map(function(t) {
                return t.group_name;
            });
            this.setData({
                hyzgm_Model: e.join(",")
            });
        },
        show_levels_CheckedAll: function(t) {
            if (t) {
                var e = this.properties.levelList.map(function(t) {
                    return t.id + "";
                });
                this.setData({
                    show_levels: e
                });
            } else this.setData({
                show_levels: []
            });
        },
        buy_levels_CheckedAll: function(t) {
            if (t) {
                var e = this.properties.levelList.map(function(t) {
                    return t.id + "";
                });
                this.setData({
                    buy_levels: e
                });
            } else this.setData({
                buy_levels: []
            });
        },
        show_groups_CheckedAll: function(t) {
            if (t) {
                var e = this.properties.groupsList.map(function(t) {
                    return t.id + "";
                });
                this.setData({
                    show_groups: e
                });
            } else this.setData({
                show_groups: []
            });
        },
        buy_groups_CheckedAll: function(t) {
            if (t) {
                var e = this.properties.groupsList.map(function(t) {
                    return t.id + "";
                });
                this.setData({
                    buy_groups: e
                });
            } else this.setData({
                buy_groups: []
            });
        }
    }
});